<style>
    .student-identity{
        margin: 3px 3px 3px 3px;
        padding: 2px 2px 2px 2px ;
    }
    .photo-img-body{
        text-align: center;
        height: 350px;

    }
    .photo-img{
        background-repeat: repeat;
        width: 260px;
        height: 340px;
        padding-right: 10px;
        line-height: 260px;
    }
    .img-body{
        text-align: center;
        font-size: 200%;
    }
    .btn-exam{
        text-align: center;
    }
    .skip-body-left{
        border: none;
        margin-left: 2%;
    }
    .skip-body-right{
        border: none;
        margin-left: 10px;
    }
    .btn-two-left{
        margin-right: 3px;
        width: auto;
        height: 360px;
    }
    .btn-two-right{
        margin-left: 3px;
        width: auto;
        height: 360px;
    }

</style>
<div class="layui-fluid">
    <form class="layui-form student-identity" action="" lay-filter="student-confirmIdentity-form">
        <div class="layui-row">
            <!--个人照片-->
            <div class="layui-col-xs10  layui-col-md-offset1">
                <div class="layui-col-xs12">
                    <div class="layui-card">
                        <div class="layui-card-body img-body">
                            <div class="photo-img-body">
                                <img id="img-photo-photoImg" data-th-src="${photo}" class="photo-img" alt="个人照片">
                                <input id="photo-stuid" name="id" data-th-value="${student.id}" type="hidden">
                                <input name="photo" data-th-value="${photo}" type="hidden">
                                <input name="remark" id="photo-disagree" type="hidden">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--驳回、审批通过、已审核按钮-->
            <div class="layui-col-xs12">
                <div class="layui-card">
                    <div class="layui-card-body btn-exam">
                        <button class="layui-btn layui-btn-danger" type="button" lay-submit=""
                                id="btn-photo-submitDisagree">驳回</button>
                        <button class="layui-btn" lay-submit="" type="button" lay-filter="student-agree-form-submit"
                                id="btn-photo-submitAgree">审批通过</button>
                        <button class="layui-btn" type="button" id="btn-photo-finish">已审核</button>
                    </div>
                </div>
            </div>
            <div class="layui-form-item febs-hide">
                <button class="layui-btn" lay-submit="" lay-filter="student-disagree-form-submit"
                        id="btn-photo-submit"></button>
            </div>
        </div>
    </form>
</div>

<script data-th-inline="javascript">
    layui.use(['febs', 'form', 'validate'], function () {
        let $ = layui.$,
            febs = layui.febs,
            layer = layui.layer,
            form = layui.form,
            student = [[${student}]],
            photo = [[${photo}]],
            validate = layui.validate;

        form.verify(validate);
        form.render();
        initBtn();

        //表单提交
        function initBtn(){
            //驳回事件弹框填写驳回原因并提交
            $("#btn-photo-submitDisagree").click(function () {
                layer.open({
                    type: 1
                    ,title: '驳回原因' //不显示标题栏
                    ,closeBtn: false
                    ,area: '300px;'
                    ,shade: 0.8
                    ,id: 'LAY_layuipro' //设定一个id，防止重复弹出
                    ,btn: ['提交', '取消']
                    ,btnAlign: 'c'
                    ,moveType: 1 //拖拽模式，0或者1
                    ,content: '<div style="padding:5px;line-height: 22px; color: #fff; font-weight: 300;' +
                        'text-align: center"><textarea id="photo-disAgreeInfo" name="remark" maxlength="200" ' +
                        'class="layui-textarea"placeholder="请填写驳回原因"></textarea></div>'
                    ,success: function(layero){
                        var btn = layero.find('.layui-layer-btn');
                        btn.find('.layui-layer-btn0').click(function(){
                            $("#photo-disagree").val($("#photo-disAgreeInfo").val());
                            if ($("#photo-disagree").val()==null||$("#photo-disagree").val()=="") {
                                febs.alert.warn('未填写驳回原因！');
                                return false;
                            }else {
                                $("#btn-photo-submit").click();
                                $("#showinfo").load("febs/views/student/affirm/photo?id="+
                                    $("#photo-stuid").val()+"&typeId=3")
                                return false;
                            }
                        })
                    }
                });
            })
            //审批通过提交
            form.on('submit(student-agree-form-submit)', function (data) {
                febs.post(ctx + 'student/affirm/agreePhoto?typeId=3',data.field,function () {
                    febs.alert.success(student.stuName + '的个人照片审核已通过');
                });
                $("#btn-photo-submitAgree").attr("style", "display:none;");
                $("#btn-photo-submitDisagree").attr("style", "display:none;");
                $("#btn-photo-finish").show();
                $("#btn-photo-submitAgree").attr("disabled",true);
                return false;
            });
            //驳回提交
            form.on('submit(student-disagree-form-submit)', function (data) {
                febs.post(ctx + 'student/affirm/rejectPhoto?typeId=3',data.field,function () {
                    febs.alert.success(student.stuName + '的个人照片审核已驳回');
                });
                $("#btn-photo-submitDisagree").attr("disabled",true);
                return false;
            });
            if (student.headImgUrl!=null&&photo==null){
                $("#img-photo-photoImg").attr("src",student.headImgUrl);
                $("#btn-photo-submitAgree").attr("style", "display:none;");
                $("#btn-photo-submitDisagree").attr("style", "display:none;");
            }else if (student.headImgUrl==null&&photo!=null){
                $("#btn-photo-finish").attr("style", "display:none;");
            }else if (student.headImgUrl!=null&&photo!=null){
                $("#btn-photo-finish").attr("style", "display:none;");
            }else if (student.headImgUrl==null&&photo==null){
                $("#img-photo-photoImg").replaceWith("<input type='text' style='border: none;" +
                    "text-align: center;margin-top: 150px;' value='个人照片未上传'>");
                $("#btn-photo-finish").attr("style", "display:none;");
                $("#btn-photo-submitAgree").attr("style", "display:none;");
                $("#btn-photo-submitDisagree").attr("style", "display:none;");
            }
            }
    });

</script>